package com.twang.stock.task;

import com.alibaba.fastjson.JSONObject;
import com.jayway.jsonpath.JsonPath;
import com.twang.stock.Entity.ShiShiData;
import com.twang.stock.common.DateUtil;
import com.twang.stock.common.http.HtmlTools;
import com.twang.stock.dto.DataObject;
import com.twang.stock.entity.*;
import com.twang.stock.entity.ex.TodayQinXuDto;
import com.twang.stock.task.old.BaseTask;
import com.twang.stock.utils.http.HttpStockUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Lists;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


/**
 * 查询大盘板块数据
 */

@Slf4j
@Service
public class QueryBanKuaiAndDaPan extends BaseTask {

    /** 1小时热度*/
   public static String  oneHourTag="oneHour";

    /** 1小时热度*/
    public static String  dayTag="24Hour";


//    @Scheduled(cron = "0 0/1 * * * ?")
    public void excute() throws Exception {
        try {
            if (!isWorkTradeTime()) {
                return;
            }
            List<DfcfZhangDie> dfcfZhangDies = getDfcfZhangDie();
            log.info("沪深 = {}", JSONObject.toJSONString(dfcfZhangDies));

            DfcfHuGangTong hgt = getHGT();
            log.info("沪港通 ={} ", JSONObject.toJSONString(hgt));

            List<DfcfBnakKuai> DfcfBnakKuai = geBKZF("je");
            log.info("概念板块 = ", JSONObject.toJSONString(DfcfBnakKuai));
        } catch (Exception e) {
            throw e;
        }
    }

    /**
     * 获取大盘数据
     *
     * @return
     */
    public static List<DfcfZhangDie> getDfcfZhangDie() {
        try {
            //
            String url = "https://push2.eastmoney.com/api/qt/ulist.np/get?secids=1.000001,0.399001&fields=f1,f2,f3,f4,f6,f12,f13,f104,f105,f106&fltt=2";
            String result = HttpStockUtils.getHtmlStrByUrl(url);
            String diff = JsonPath.read(result, "$.data.diff").toString();
            List<DfcfZhangDie> list = JSONObject.parseArray(diff, DfcfZhangDie.class);
            return list;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;

    }

    /**
     * 获取沪港通数据:
     *  fields1 : f1、f3代表北上，f2、f4代表南向
     *
     * @return
     */
    public static DfcfHuGangTong getHGT() throws Exception {
        //
        String url = "https://push2.eastmoney.com/api/qt/kamt/get?fields1=f1,f2,f3,f4&fields2=f51,f52,f53,f54,f55,f56,f57,f58,f59";
        String result = HttpStockUtils.getHtmlStrByUrl(url);
        Map data = JsonPath.read(result, "$.data");
        DfcfHuGangTong dfcfHuGangTong = JSONObject.parseObject(JSONObject.toJSONString(data), DfcfHuGangTong.class);
        return dfcfHuGangTong;
    }

    /**
     * 获取沪港通数据:
     *  fields1 : f1、f3代表北上，f2、f4代表南向
     *
     * @return
     */
    public static HkShMoneyInOut getHGTInOut() throws Exception {
        //沪
        String mutualType_001 = "001";
        //南向
        String mutualType_002 = "002";
        //深
        String mutualType_003 = "003";
        //
        String url = "http://datacenter-web.eastmoney.com/api/data/v1/get?reportName=RPT_MUTUAL_QUOTA&columns=TRADE_DATE%2CMUTUAL_TYPE%2CBOARD_TYPE%2CMUTUAL_TYPE_NAME%2CFUNDS_DIRECTION%2CINDEX_CODE%2CINDEX_NAME%2CBOARD_CODE&quoteColumns=status~07~BOARD_CODE%2CdayNetAmtIn~07~BOARD_CODE%2CdayAmtRemain~07~BOARD_CODE%2CdayAmtThreshold~07~BOARD_CODE%2Cf104~07~BOARD_CODE%2Cf105~07~BOARD_CODE%2Cf106~07~BOARD_CODE%2Cf3~03~INDEX_CODE~INDEX_f3%2CnetBuyAmt~07~BOARD_CODE&quoteType=0&pageNumber=1&pageSize=200&sortTypes=1&sortColumns=MUTUAL_TYPE&source=WEB&client=WEB";
        String result = HttpStockUtils.getHtmlStrByUrlUtf8(url);
//
//        String data = JsonPath.read(result, "$.result.data").toString();
//       // String str=JSON.parseObject(JSONObject.parseObject(JSONObject.toJSONString(result)).getJSONObject("result").toJSONString()).getJSONObject("data").toJSONString();
//        List<DfcfZhangDie> list = JSONObject.parseArray(diff, DfcfZhangDie.class);

        List<HkShMoneyInOut> hkShMoneyInOutList = JSONObject.parseArray(JsonPath.read(result, "$.result.data").toString(), HkShMoneyInOut.class);
        HkShMoneyInOut hkShMoneyInOut = new HkShMoneyInOut();
        for (HkShMoneyInOut item : hkShMoneyInOutList) {
            //汇总
            if (mutualType_003.equals(item.getMutualType()) || mutualType_001.equals(item.getMutualType())) {
                //北上净流入
                BigDecimal netBuyAmt = hkShMoneyInOut.getNetBuyAmt().add(item.getNetBuyAmt());
                if (null == netBuyAmt) {
                    netBuyAmt = BigDecimal.ZERO;
                }
                hkShMoneyInOut.setNetBuyAmt(netBuyAmt);

                //上涨
                BigDecimal szNum = (hkShMoneyInOut.getSzNum() == null ? BigDecimal.ZERO : hkShMoneyInOut.getSzNum()).add(item.getSzNum());
                hkShMoneyInOut.setSzNum(szNum);
                //下跌
                BigDecimal xdNum = (hkShMoneyInOut.getXdNum() == null ? BigDecimal.ZERO : hkShMoneyInOut.getXdNum()).add(item.getXdNum());
                hkShMoneyInOut.setXdNum(xdNum);
                //持平
                BigDecimal noneNum = (hkShMoneyInOut.getNoneNum() == null ? BigDecimal.ZERO : hkShMoneyInOut.getNoneNum()).add(item.getNoneNum());
                hkShMoneyInOut.setNoneNum(noneNum);

            } else if (mutualType_002.equals(item.getMutualType())) {
                //获取恒生指数
                hkShMoneyInOut.setIndexF3(item.getIndexF3());
            }

        }
        hkShMoneyInOut.setNetBuyAmt(hkShMoneyInOut.getNetBuyAmt().divide(new BigDecimal(10000)).setScale(2, BigDecimal.ROUND_HALF_UP));
        return hkShMoneyInOut;
    }


    /**
     * 获取今日板块涨幅排行
     * orderByFlag:
     * je:按金额排序
     * zd：按涨跌幅排序
     *
     * @return
     */
    public static List<DfcfBnakKuai> geBKZF(String orderByFlag) throws Exception {
        String url = "";
        //金额
        if ("je".equals(orderByFlag)) {
            url = "https://push2.eastmoney.com/api/qt/clist/get?cb=jQuery1123001903264754657874_1676619527949&fid=f62&po=1&pz=50&pn=1&np=1&fltt=2&invt=2&ut=b2884a393a59ad64002292a3e90d46a5&fs=m%3A90+t%3A3&fields=f12%2Cf14%2Cf2%2Cf3%2Cf62%2Cf184%2Cf66%2Cf69%2Cf72%2Cf75%2Cf78%2Cf81%2Cf84%2Cf87%2Cf204%2Cf205%2Cf124%2Cf1%2Cf13";
        } else {
            //url = "https://push2.eastmoney.com/api/qt/clist/get?cb=jQuery1123001903264754657874_1676619527949&fid=f3&po=1&pz=50&pn=1&np=1&fltt=2&invt=2&ut=b2884a393a59ad64002292a3e90d46a5&fs=m%3A90+t%3A3&fields=f12%2Cf14%2Cf2%2Cf3%2Cf62%2Cf184%2Cf66%2Cf69%2Cf72%2Cf75%2Cf78%2Cf81%2Cf84%2Cf87%2Cf204%2Cf205%2Cf124%2Cf1%2Cf13";
            url = "https://push2.eastmoney.com/api/qt/clist/get?cb=jQuery112302556740450324666_1691496553513&fid=f3&po=1&pz=50&pn=1&np=1&fltt=2&invt=2&ut=b2884a393a59ad64002292a3e90d46a5&fs=m%3A90+t%3A2&fields=f12%2Cf14%2Cf2%2Cf3%2Cf62%2Cf184%2Cf66%2Cf69%2Cf72%2Cf75%2Cf78%2Cf81%2Cf84%2Cf87%2Cf204%2Cf205%2Cf124%2Cf1%2Cf13";
        }
        String result = HttpStockUtils.getHtmlStrByUrlUtf8(url);
        String diff = JsonPath.read(result.split("\\(")[1].split("\\);")[0], "$.data.diff").toString();
        List<DfcfBnakKuai> list = JSONObject.parseArray(diff, DfcfBnakKuai.class);
        List<DfcfBnakKuai> resultList = Lists.newArrayList();
        int size=5;
        for (int i = 0; i <= size; i++) {
            DfcfBnakKuai dfcfBnakKuai= list.get(i);
            if(dfcfBnakKuai.getBkName().contains("昨日")||dfcfBnakKuai.getBkName().contains("连板")){
                size++;
                continue;
            }
            if (dfcfBnakKuai.getTag() != 0) {
                size++;
                continue;
            }
            resultList.add(dfcfBnakKuai);
        }
        return resultList;
    }

    /**
     * 获取同华顺
     * orderByFlag:
     *          oneHour:1小时热度
     *          day：24小时热度
     * Num--0代表全部，有数字代表条数
     *
     *
     * @return
     */
    public static List<ThsHotStock> getHotStockList(String orderByFlag,int num) throws Exception {
        String url = "";
        //金额
        if ("oneHour".equals(orderByFlag)) {
            url = "https://eq.10jqka.com.cn/open/api/hot_list/v1/hot_stock/a/hour/data.txt";
        } else {
            url = "https://eq.10jqka.com.cn/open/api/hot_list/v1/hot_stock/a/day/data.txt";
        }
        String result = HttpStockUtils.getHtmlStrByUrlUtf8(url);
        String diff = JsonPath.read(result, "$.data.stock_list").toString();
        List<ThsHotStock> list = JSONObject.parseArray(diff, ThsHotStock.class);
        if(CollectionUtils.isNotEmpty(list)){
            List<String> code=Lists.newArrayList();
            for (ThsHotStock companyCodeInfo : list) {
                String codes = companyCodeInfo.getCode();
                if (codes.startsWith("3") || codes.startsWith("0")) {
                    codes = "sz" + codes;
                } else {
                    codes = "sh" + codes;
                }
                code.add(codes);
            }
            try {
                List<ShiShiData> shiShiDataList = HtmlTools.getGpdatas(Lists.newArrayList(code));
                for (ThsHotStock thsHotStock : list) {
                    String codes = thsHotStock.getCode();
                    if (codes.startsWith("3") || codes.startsWith("0")) {
                        codes = "sz" + codes;
                    } else {
                        codes = "sh" + codes;
                    }
                    String finalCodes = codes;
                    List<ShiShiData> shiShiDataListTemp=shiShiDataList.stream().filter(p->p.getCode().equals(finalCodes)).collect(Collectors.toList());
                    if(CollectionUtils.isNotEmpty(shiShiDataListTemp)){
                        thsHotStock.setZhangdie(shiShiDataListTemp.get(0).getZhangdie());
                    }
                }
            return list;
            }catch (Exception e){
                log.error("getHotStockList-->code={},error:{}",code,e);
            }
        }
//        List<ThsHotStock> resultList = Lists.newArrayList();
//        int size=(num==0?list.size()-1:num);
//        for (int i = 0; i <= size; i++) {
//            ThsHotStock thsHotStock=list.get(i);
//            //
//            String code=thsHotStock.getCode();
//            if(code.startsWith("3")||code.startsWith("0")){
//                code="sz"+code;
//            }else{
//                code="sh"+code;
//            }
//            try {
//                List<ShiShiData> shiShiDataList = HtmlTools.getGpdatas(Lists.newArrayList(code));
//                ShiShiData shiShiData = shiShiDataList.get(0);
//                thsHotStock.setZhangdie(shiShiData.getZhangdie());
//            }catch (Exception e){
//                log.error("getHotStockList-->code={},error:{}",code,e);
//            }
//            resultList.add(list.get(i));
//        }
//        return resultList;
        return null;
    }

    /**
     * 获取大盘数据
     * @return
     */
    public static TodayQinXuDto getTodayQinXu(){
        TodayQinXuDto todayQinXu = new TodayQinXuDto();
        todayQinXu.setDate(DateUtil.getToday().substring(0, 8));
        try {
            String htmlForStock =  HttpStockUtils.getHtmlStrByUrlUtf8("http://q.10jqka.com.cn/api.php?t=indexflash&");
            // 网页内容解析
            log.info("该网页存在,正在解析:{}", htmlForStock);
            //获取分时涨停数
            todayQinXu.setNowZtzs(new BigDecimal(JsonPath.read(htmlForStock, "$.zdt_data.last_zdt.ztzs").toString()));
            //获取分时跌停数
            todayQinXu.setNowDtzs(new BigDecimal(JsonPath.read(htmlForStock, "$.zdt_data.last_zdt.dtzs").toString()));
            //获取分时涨停数集合【9：30-11：30，13：00-15：00】
            List<String> times = JsonPath.read(htmlForStock, "$.zdt_data.zd_time");
            todayQinXu.setMinutes(times.get(times.size() - 1).replace(":", ""));
            //全A涨跌分布（上涨）
            JsonPath.read(htmlForStock, "$.zdfb_data.znum");
            todayQinXu.setZtzs(new BigDecimal(JsonPath.read(htmlForStock, "$.zdfb_data.znum").toString()));
            //全A涨跌分布（下跌）
            JsonPath.read(htmlForStock, "$.zdt_data.dtzs");
            todayQinXu.setDtzs(new BigDecimal(JsonPath.read(htmlForStock, "$.zdfb_data.dnum").toString()));
            //沪市成交量
            List<ShiShiData> shiShiDatas  =HtmlTools.getGpdatas(Lists.newArrayList("sh000001"));
            if(CollectionUtils.isNotEmpty(shiShiDatas)) {
                ShiShiData shiShiData = shiShiDatas.get(0);
                // 发送请求，并执行
                // StockFromTHSDto stockFromTHSDto= ExcuteWarningTask.getData("1A0001");
                todayQinXu.setShTradeVol(new BigDecimal(shiShiData.getSumvol()));
                //沪市成交额
                todayQinXu.setShTradeSum(new BigDecimal(shiShiData.getAmount()));
                //深市成交量
                shiShiData = HtmlTools.getGpdatas(Lists.newArrayList("sz399006")).get(0);
                todayQinXu.setSzTradeVol(new BigDecimal(shiShiData.getSumvol()));
                //深市成交量
                todayQinXu.setSzTradeSum(new BigDecimal(shiShiData.getAmount()));
            }
            //大盘大单净流入
            todayQinXu.setDdjlr(大盘大单净流入());

        } catch (Exception e) {
            log.error("erro={}", e);
        }
        return todayQinXu;
    }

    public static BigDecimal 大盘大单净流入() throws Exception {
        String url = "https://push2.eastmoney.com/api/qt/stock/fflow/kline/get?cb=jQuery112305385740855560706_1676915701352&lmt=0&klt=1&fields1=f1%2Cf2%2Cf3%2Cf7&fields2=f51%2Cf52%2Cf53%2Cf54%2Cf55%2Cf56%2Cf57%2Cf58%2Cf59%2Cf60%2Cf61%2Cf62%2Cf63%2Cf64%2Cf65&ut=b2884a393a59ad64002292a3e90d46a5&secid=1.000001&secid2=0.399001&_=1676915701353";
        String result = HttpStockUtils.getHtmlStrByUrl(url);
        String diff = JsonPath.read(result.split("\\(")[1].split("\\);")[0], "$.data.klines").toString();
        List<String> list = JSONObject.parseArray(diff, String.class);
        for(int i=list.size()-1;i>=0;i--){
            String str=list.get(i);
            if(str.split(",")[1].length()>1){
                return new BigDecimal(str.split(",")[1]);
            }
        }
        return BigDecimal.ZERO;
    }


    /**
     * 获取沪港通数据:
     *  fields1 : f1、f3代表北上，f2、f4代表南向
     *
     * @return
     */
    public static List<CompanyStockMinutes> 个股分时数据明细(String companyCode) throws Exception {
        //
        String bankuai="0";
        if("sh".contains(companyCode)){
             bankuai="1";
        }
        String code=companyCode.substring(2,8);
        String url = "http://push2.eastmoney.com/api/qt/stock/trends2/get?secid="+bankuai+"."+code+"&fields1=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f11,f12&fields2=f51,f52,f53,f54,f55,f56,f57,f58";
        String result = HttpStockUtils.getHtmlStrByUrl(url);
        String diff = JsonPath.read(result, "$.data.trends").toString();
        List<String> list = JSONObject.parseArray(diff, String.class);
        List<CompanyStockMinutes> companyStockMinutesList=Lists.newArrayList();
        for (int i = list.size() - 1; i >= 0; i--) {
            CompanyStockMinutes companyStockMinutes=new CompanyStockMinutes();
            String[] str = list.get(i).split(",");
            companyStockMinutes.setDate(str[0].split(" ")[0].replace("-",""));
            companyStockMinutes.setMinutes(str[0].split(" ")[1]);
            companyStockMinutes.setVol(new BigDecimal(str[5]));
            companyStockMinutes.setAmount(new BigDecimal(str[6]));
            companyStockMinutes.setCompanyCode(companyCode);
            companyStockMinutesList.add(companyStockMinutes);
        }
        return companyStockMinutesList;
    }
    /**
     *  fs:b:BK1128+f:!2
     *
     * @return
     */
    public static List<DfcfBanKuaiMaoLiLv> 获取板块咱得排行个股(String bankuai) throws Exception {
        String url = "https://push2.eastmoney.com/api/qt/clist/get?fid=f3&po=1&pz=500&pn=1&np=1&fs=b:"+bankuai+"&fields=f12,f14,f2,f3,f62,f184,f66,f69,f72,f75,f78,f81,f84,f87,f204,f205,f124,f1,f13";
        String result = HttpStockUtils.getHtmlStrByUrlUtf8(url);
        String diff = JsonPath.read(result, "$.data.diff").toString();
        List<String> list = JSONObject.parseArray(diff, String.class);
        List<DfcfBanKuaiMaoLiLv> dfcfBanKuaiMaoLiLvList=Lists.newArrayList();
        for (int i=0; i <list.size(); i++) {
            DfcfBanKuaiMaoLiLv dfcfBanKuaiMaoLiLv = JSONObject.parseObject(list.get(i), DfcfBanKuaiMaoLiLv.class);
            try{
                {
                    String zhangDie=dfcfBanKuaiMaoLiLv.getZhangDie();
                    if(StringUtils.isNotEmpty(zhangDie)) {
                        StringBuffer bf = new StringBuffer("");
                        if (zhangDie.startsWith("-")) {
                            zhangDie = zhangDie.replace("-", "");
                            bf.append("-");
                        }
                        if (zhangDie.length() == 4) {
                            bf.append(zhangDie.substring(0, 2)).append(".").append(zhangDie.substring(2, 4));
                        } else if (zhangDie.length() == 3) {
                            bf.append(zhangDie.substring(0, 1)).append(".").append(zhangDie.substring(2, 3));
                        } else if (zhangDie.length() == 2) {
                            bf.append("0.").append(zhangDie.substring(0,2));
                        }
                        dfcfBanKuaiMaoLiLv.setZhangDie(bf.toString());
                        dfcfBanKuaiMaoLiLv.setMll(new BigDecimal(StringUtils.isEmpty(dfcfBanKuaiMaoLiLv.getZhangDie())?"0":dfcfBanKuaiMaoLiLv.getZhangDie()));
                    }
                }
                dfcfBanKuaiMaoLiLv.setKanDian(查询个股热点(dfcfBanKuaiMaoLiLv.getCode()));
            }catch (Exception e){
                log.error("查詢公司看点出错,{}",e);
            }
            dfcfBanKuaiMaoLiLvList.add(dfcfBanKuaiMaoLiLv);
        }
        return dfcfBanKuaiMaoLiLvList;
    }

    /**
     *  查询个股热点
     *
     * @return
     */
    public static List<ThsGeGuReZDian> 查询个股热点(String code) throws Exception {
        if(StringUtils.isEmpty(code)){
            return null;
        }
        String url = "https://eq.10jqka.com.cn/open/api/stock_view_v2/homepage?stockCode="+code+"&marketId=17";
        String result = HttpStockUtils.getHtmlStrByUrlUtf8(url);

        String diff = JsonPath.read(result, "$.data.labels").toString();
        List<ThsGeGuReZDian> list = JSONObject.parseArray(diff, ThsGeGuReZDian.class);
        List<ThsGeGuReZDian> newList=Lists.newArrayList();
        for(int i=list.size()-1;i>=0;i--){
            newList.add(list.get(i));
        }
        //return newList ;
        return Lists.newArrayList();
    }


    /**
     *
     * @param
     * @throws Exception
     */
    public static  List<DataObject> 今年涨幅前20个股() throws Exception {
        String url="http://www.iwencai.com/customized/chart/get-robot-data";
        String key="";
        key="今年涨幅前30个股";
        //key="一个月内涨幅超50%的的个股";
        String result = HttpStockUtils.getHtmlStrByUrlPOST(url,key);
        String diff = JsonPath.read(result, "$.data.answer[0].txt[0].content.components[0].data.datas").toString();
        List<JSONObject> list=JSONObject.parseArray(diff, JSONObject.class);
        List<DataObject> lists=Lists.newArrayList();
        list.forEach(item->{
          Object obj=  item.get(DataObject.nameKey);
            DataObject data= JSONObject.parseObject(item.toJSONString(),DataObject.class);
                if(null!=obj){
                    data.setChangeRate(new BigDecimal(obj.toString()).setScale(0,BigDecimal.ROUND_HALF_UP));
                }
            lists.add(data);
        });
        log.info(">>>>>>>>>>>  今年涨幅前20个股 list={}",JSONObject.toJSONString(lists));
        return lists;
    }



    private static final String API_KEY = "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";
    private static final String API_URL = "https://api.openai.com/v1/models";



    private static void CHatGPTAPI() {
        try {
            URL url = new URL(API_URL);
            HttpURLConnection conn = (HttpURLConnection) url.openConnection();

            conn.setRequestMethod("GET");
            conn.setRequestProperty("Authorization", "Bearer " + API_KEY);

            int responseCode = conn.getResponseCode();
            System.out.println("Response Code : " + responseCode);

            BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()));
            String output;
            StringBuffer response = new StringBuffer();

            while ((output = in.readLine()) != null) {
                response.append(output);
            }
            in.close();

            System.out.println("Response: " + response.toString());

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 涨停聚焦
     * @param url
     * @param date
     * @param type  1-涨停池，2-连板池，3-连板池
     * @return
     * @throws Exception
     */
    public static ZhangTingJuJiaoDto 涨停聚焦(String url,String date,String type) throws Exception {
        if (StringUtils.isEmpty(date)) {
            return null;
        }
        url = url + date;
        String result = HttpStockUtils.getHtmlStrByUrlUtf8(url);
        ZhangTingJuJiaoDto zhangTingJuJiaoDto=null;
        String str = JSONObject.toJSONString(JsonPath.read(result, "$.data"));
        if (StringUtils.isNotEmpty(str)) {
            zhangTingJuJiaoDto = JSONObject.parseObject(str, ZhangTingJuJiaoDto.class);
            if (null != zhangTingJuJiaoDto) {
                List<ZhangTingJuJiao> list = zhangTingJuJiaoDto.getInfo();
                if (CollectionUtils.isNotEmpty(list)) {
                    for (int i = list.size() - 1; i >= 0; i--) {
                        ZhangTingJuJiao zhangTingJuJiao = list.get(i);
                        SimpleDateFormat sd = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
                        if(StringUtils.isNotEmpty(zhangTingJuJiao.getFirstLimitUpTime())){
                            zhangTingJuJiao.setFirstLimitUpTime(sd.format(new Date(Long.valueOf(zhangTingJuJiao.getFirstLimitUpTime() + "000"))));
                        }
                        if(StringUtils.isNotEmpty(zhangTingJuJiao.getLastLimitUpTime())){
                            zhangTingJuJiao.setLastLimitUpTime(sd.format(new Date(Long.valueOf(zhangTingJuJiao.getLastLimitUpTime() + "000"))));
                        }
                        if(null!=zhangTingJuJiao.getCurrencyValue()){
                            zhangTingJuJiao.setCurrencyValue(zhangTingJuJiao.getCurrencyValue().setScale(6,BigDecimal.ROUND_HALF_UP));
                        }
                        if(null!=zhangTingJuJiao.getLimitUpSucRate()){
                            zhangTingJuJiao.setLimitUpSucRate(zhangTingJuJiao.getLimitUpSucRate().setScale(6,BigDecimal.ROUND_HALF_UP));
                        }
                        if(null!=zhangTingJuJiao.getChangeRate()){
                            zhangTingJuJiao.setChangeRate(zhangTingJuJiao.getChangeRate().setScale(6,BigDecimal.ROUND_HALF_UP));
                        }
                        if(null!=zhangTingJuJiao.getRiseRate()){
                            zhangTingJuJiao.setRiseRate(zhangTingJuJiao.getRiseRate().setScale(6,BigDecimal.ROUND_HALF_UP));
                        }
                        if(null!=zhangTingJuJiao.getTurnoverRate()){
                            zhangTingJuJiao.setTurnoverRate(zhangTingJuJiao.getTurnoverRate().setScale(6,BigDecimal.ROUND_HALF_UP));
                        }
                        if(null!=zhangTingJuJiao.getTurnover()){
                            zhangTingJuJiao.setTurnover(zhangTingJuJiao.getTurnover().setScale(6,BigDecimal.ROUND_HALF_UP));
                        }
                        if(null!=zhangTingJuJiao.getOrderAmount()){
                            zhangTingJuJiao.setOrderAmount(zhangTingJuJiao.getOrderAmount().setScale(6,BigDecimal.ROUND_HALF_UP));
                        }
                        if(null!=zhangTingJuJiao.getLatest()){
                            zhangTingJuJiao.setLatest(zhangTingJuJiao.getLatest().setScale(6,BigDecimal.ROUND_HALF_UP));
                        }
                        zhangTingJuJiao.setDate(date);
                        zhangTingJuJiao.setOrderType(type);
                    }
                }
            }
        }
        log.info(">>>>> 涨停聚焦 type={} Response={} ", type, JSONObject.toJSONString(zhangTingJuJiaoDto));
        return zhangTingJuJiaoDto;
    }

    public static void main(String[] args) throws Exception {
        String date="20231013";
        //涨停版
        String  url = "https://data.10jqka.com.cn/dataapi/limit_up/limit_up_pool?page=1&limit=15&field=199112,10,9001,330323,330324,330325,9002,330329,133971,133970,1968584,3475914,9003,9004&filter=HS,GEM2STAR&order_field=330324&order_type=0&_=1697188532792&date=";
         涨停聚焦(url,date,"1");

        //连扳池
        url = "https://data.10jqka.com.cn/dataapi/limit_up/continuous_limit_pool?page=1&limit=15&field=199112,10,330329,330325,133971,133970,1968584,3475914,3541450,9004&filter=HS,GEM2STAR&order_field=330329&order_type=0&_=1697277852030&date=";
        涨停聚焦(url,date,"2");

        //炸板池
         url = "https://data.10jqka.com.cn/dataapi/limit_up/open_limit_pool?page=1&limit=15&field=199112,9002,48,1968584,19,3475914,9003,10,9004&filter=HS,GEM2STAR&order_field=199112&order_type=0&_=1697276712736&date=";
        涨停聚焦(url,date,"3");

        //冲刺涨停
        url = "https://data.10jqka.com.cn/dataapi/limit_up/limit_up?page=1&limit=15&field=199112,10,48,1968584,19,3475914,9003,9004&filter=HS,GEM2STAR&order_field=199112&order_type=0&_=1697276709844&date=";
        涨停聚焦(url,date,"4");

        //跌停池
        url = "https://data.10jqka.com.cn/dataapi/limit_up/lower_limit_pool?page=1&limit=15&field=199112,10,330333,330334,1968584,3475914,9004&filter=HS,GEM2STAR&order_field=330334&order_type=0&_=1697277854794&date=";
        涨停聚焦(url,date,"5");

    }

}
